package dto.utils;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

public class DataTransferObject implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String sender;
	private List<String> receivers;
	private long startTime;
	private long endTime;
	private long duration;
	
	private String title;
	private String where;
	private String description;
	private FasciaOraria preferenza;
	private int min;
	private int max;
	
	private List<SingleEvent> events;
	
	private TimeZone timeZone;

	public DataTransferObject() {
		this.sender = "";
		this.receivers = new ArrayList<String>();
		this.startTime = 0;
		this.endTime = 0;
		this.duration = 0;
		this.title = "";
		this.where = "";
		this.description = "";
		this.preferenza = new FasciaOraria();
		this.events = new ArrayList<SingleEvent>();
		this.min=1;
		this.max=0;
		timeZone = TimeZone.getDefault();
	}
	
	

	public DataTransferObject(String sender, List<String> receivers,
			long startTime, long endTime, long duration, String title,
			String where, String description, FasciaOraria preferenza,
			List<SingleEvent> events, int min, int max) {
		super();
		this.sender = sender;
		this.receivers = receivers;
		this.startTime = startTime;
		this.endTime = endTime;
		this.duration = duration;
		this.title = title;
		this.where = where;
		this.description = description;
		this.preferenza = preferenza;
		this.events = events;
		this.min=min;
		this.max=max;
		timeZone = TimeZone.getDefault();
	}

	
	public TimeZone getTimeZone() {
		return timeZone;
	}



	public void setTimeZone(TimeZone timeZone) {
		this.timeZone = timeZone;
	}



	public String getSender() {
		return sender;
	}
	public void setSender(String sender) {
		this.sender = sender;
	}
	public void setTime(long startTime, long endTime)
	{
		this.startTime = startTime;
		this.endTime = endTime;
	}

	public long getStartTime() {
		return startTime;
	}

	public long getEndTime() {
		return endTime;
	}

	public List<String> getReceivers() {
		return receivers;
	}

	public void setReceivers(List<String> receivers) {
		this.receivers = receivers;
	}

	public long getDuration() {
		return duration;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getWhere() {
		return where;
	}

	public void setWhere(String where) {
		this.where = where;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setDuration(long duration) {
		this.duration = duration;
	}
	
	public FasciaOraria getPreferenza() {
		return preferenza;
	}

	public void setPreferenza(FasciaOraria preferenza) {
		this.preferenza = preferenza;
	}
	
	public List<SingleEvent> getEvents() {
		return events;
	}

	public void setEvents(List<SingleEvent> events) {
		this.events = events;
	}

	@Override
	public String toString() {
		
		Date dateDA = new Date(startTime);
		Date dateA = new Date(endTime);
		
		return dateDA+" ||||||||| "+dateA;
	}

	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}

	public void setEndTime(long endTime) {
		this.endTime = endTime;
	}

	public int getMin() {
		return min;
	}

	public void setMin(int min) {
		this.min = min;
	}

	public int getMax() {
		return max;
	}

	public void setMax(int max) {
		this.max = max;
	}
	
	/**
	 * 
	 * @return restituisce il numero dei giorni nel range di ricenca
	 */
	public int getNumeroGiorniNelRange(){
		
		long millisecondiInUnGiorno=  86400000;
		int giorni = (int) ((endTime - startTime) / millisecondiInUnGiorno);;
		return   giorni; 
		
	}
	
}
